{extend name="public:layout" /}
{block name="title"}优惠券列表{/block}
{block name="head"}
{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 优惠券列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <a class="btn btn-primary" href="{:url('add')}">
                        <i class="fa fa-plus"></i>&nbsp;添加优惠券
                    </a>
                </div>
                <div class="pull-right">
                    <form class="form-inline" method="post" id="searchForm">
                        <input type="hidden" id="status" name="status" value="{$query.status}" />
                        <div class="form-group">
                            <div class="input-group">
                                <input class="form-control" id="title" name="title" type="text" value="{$query.title}" placeholder="请输入优惠卡券名称">
                            </div>
                        </div>
                        <button type="submit" class="btn btn-info">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a class="btn btn-white" href="{:url('index')}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <ul class="nav nav-tabs" id="tab_search">
                <li data-status="1" {eq name="query.status" value="1"}class="active"{/eq}><a href="javascript:;">进行中</a></li>
                <li data-status="0" {eq name="query.status" value="0"}class="active"{/eq}><a href="javascript:;">已失效</a></li>
            </ul>
            <script>
                $(function () {
                    $('#tab_search li').click(function () {
                        var status=$(this).data('status');
                        $('#status').val(status);
                        $('#searchForm').submit();
                    });
                })
            </script>
            <table class="table" id="grid">
                <tr>
                    <th width="40">#</th>
                    <th>优惠卷名称</th>
                    <th>发放类型</th>
                    <th>面额</th>
                    <th>有效期</th>
                    <th>库存</th>
                    <th>已领取</th>
                    <th>已使用</th>
                    <th width="150">操作</th>
                    <th width="210"></th>
                </tr>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo.card_id}</td>
                    <td>
                        <a href="javascript:;" style="color:#333;"
                           data-html="true"
                           data-toggle="tooltip"
                           data-placement="right"
                           title="<p align='left'>
                                名称:{$vo.title}<br/>
							    副标题:{$vo.sub_title}<br/>
							    有效期:[{$vo.begin_date}]-[{$vo.end_date}]<br/>
                                使用说明:{$vo.direction}
                                </p>">
                            {$vo.title}
                        </a>
                    </td>
                    <td>{$vo.send_type_text}</td>
                    <td>{$vo.card_money}</td>
                    <td>[{$vo.begin_date}]-[{$vo.end_date}]</td>
                    <td>{$vo.quantity}</td>
                    <td>{$vo.receive_num}</td>
                    <td>{$vo.use_num}</td>
                    <td>
                        <a href="{:url('edit',['card_id'=>$vo['card_id']])}">修改</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="此操作不可逆！<br/>确认删除吗？" data-url="{:url('del')}"
                           data-params="card_id={$vo.card_id}">删除</a>
                    </td>
                    <td>

                        <a href="{:url('viewCardKey',['card_id'=>$vo['card_id']])}" class="btn btn-sm btn-warning">卡券领取列表</a>
                        {eq name="vo.send_type" value="0"}
                        <a href="{:url('sendCardKey',['card_id'=>$vo['card_id']])}" class="btn btn-sm btn-primary">发放优惠券</a>
                        {/eq}
                        {eq name="vo.send_type" value="1"}
                        <a href="{:url('buildCardKey',['card_id'=>$vo['card_id']])}" class="btn btn-sm btn-success">&nbsp;&nbsp;卡券生成&nbsp;&nbsp;</a>
                        {/eq}
                        {eq name="vo.send_type" value="2"}
                        <a href="{:url('orderList',['card_id'=>$vo['card_id']])}" class="btn btn-sm btn-success">&nbsp;&nbsp;购买列表&nbsp;&nbsp;</a>
                        {/eq}
                    </td>
                </tr>
                {/volist}
            </table>
            <div class="page-bar">{$list->render()}</div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function(){
        $('[data-toggle="tooltip"]').tooltip()
    })
</script>
{/block}